<template>
  <div>
    <h2>用户添加借款信息</h2>
    <table border="1">
      <tr>
        <td>借款名称</td>
        <td>
          <input type="text" v-model="info.jname">
        </td>
      </tr>
      <tr>
        <td>借款最高金额</td>
        <td>
          <input type="text" v-model="info.maxprice">
        </td>
      </tr>
      <tr>
        <td>借款年限</td>
        <td>
          <input type="text" v-model="info.year">年
        </td>
      </tr>
      <tr>
        <td>利息</td>
        <td>
          <select v-model="info.lixi">
            <option value="">请选择</option>
            <option value="1%">1%</option>
            <option value="2%">2%</option>
            <option value="3%">3%</option>
            <option value="4%">4%</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>借款简介</td>
        <td>
          <input type="textarea" v-model="info.show">
        </td>
      </tr>
      <tr>
        <td>借款发布时间</td>
        <td>
          <input type="date" v-model="info.date">
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <input type="button" value="借款" @click="jiekuan">
        </td>

      </tr>
    </table>
    

  </div>
</template>

<script setup lang="ts">
import { ref ,onMounted} from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router=useRouter();

const info=ref({
  jname:"",
  maxprice:"",
  year:"",
  lixi:"",
  show:"",
  date:"",
  de:true,
})
//借款
const jiekuan=()=>{
  axios({
    url:"http://localhost:59085/api/CF/Add",
    method:"post",
    data:info.value
  }).then((res)=>{
    if(res.data>0){
      alert("借款成功");
    }
    else
    {
      alert("借款失败");
    }
    //异常处理
  }).catch((err)=>{
    console.log(err);
  })

}






</script>



<style scoped>

</style>